<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
    <title></title>
    <meta charset="utf-8"> 
    <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
	<link rel="stylesheet" href="mytask/css/ui-baselb.css?v=202022">
    <link rel="stylesheet" href="mytask/css/ui-imglb.css?v=202022">
    <link rel="stylesheet" href="mytask/css/ui-boxlb.css?v=202022">
    <link rel="stylesheet" href="mytask/css/ui-colorlb.css?v=202022">
	<script src="js/jquery-1.11.1.min.js"></script>
	<script src="js/iBox.js"></script>
	<script src="js/main.js"></script>
	<style>
	.bd1{ 
	 border:1px solid;   
	}
	.bbt1{
     border-bottom:1px solid #cccccc;   
    }
	.bod1{
        border-radius: .1em
    }
    .bod2{
        border-radius: .2em
    }
	.bod3{
	    border-radius: .3em
	}
	</style>
</head>
<body class="um-vp" ontouchstart style="height: 100%;overflow: hidden;"> 
    <div tit class="m3">
    <div class="p3 bod2" style="background: rgba(255,255,255,.3);"> 
       <div class="ub mt10">
           <div class="w30">距离：</div>
           <div se class="wtp40 ub ml5">
               <div tx class="bc1 wtp85 pl5">1公里</div> 
               <div class="img137 bc85 p4"></div>  
               <select>
                   <option>1公里</option>
                   <option>2公里</option>
                   <option>3公里</option>
                   <option>4公里</option>
                   <option>5公里</option>
                   <option>6公里</option>
                   <option>7公里</option>
                   <option>8公里</option>
                   <option>9公里</option>
                   <option>10公里</option>
               </select>
           </div>
       </div>     
       <div class="ub mt15">
           <div class="w30">航站：</div>
           <div hz class="wtp40 ub ml5">
               <div class="bc1 wtp85 pl5" code="SHA">上海虹桥</div>
               <div class="img137 bc85 p4"></div>
           </div> 
       </div>       
       <div class="ub ub-pc mt20 pb10"> 
            <div search class="c1 w55 tx-c pt3 pb3 bd1 bod3">搜索</div>
       </div> 
    </div>  
    <div id="list" class="mt5 bod3" style="background: rgba(255,255,255,.4);overflow: auto">
    </div> 
    </div>
</body>
<script>
window.uexOnload=function(){
    iP.init()
}
var iP={};
var distance=1,index=0,totalPage=0;
var dheight=document.body.scrollHeight;
var tit= parseInt($("[tit]").css("height")); 
$("#list").css("max-height",(dheight-tit)*.95+"px");
iP.init=function(){
    $("[se] select").on("change",function(){
        $("[tx]").text($(this).val())  
    }) 
    if(localStorage.getItem("airport3zm")==undefined||localStorage.getItem("airport3zm")==null){
    }else{  
        $("[code]").text(localStorage.getItem("portname")); 
        $("[code]").attr("code",localStorage.getItem("airport3zm"));
    } 
    $("[search]").click(function(){
       var kml=$("[tx]").text();
       distance=parseInt(kml);
       $("#list").html('');
       index=0;
       iP.load();
    });
    iP.pulldown(iP.load())
};
$("[hz]").click(function(){
    localStorage.setItem("html", "Bookinghotel_win");
    openNewWin('airport', 'airport.html');
})
function setAirPort(name, code){
     $("[code]").text(name); 
     $("[code]").attr("code",code);
     index=0;
}
iP.renull=function(a){
    if(a==undefined||a=="undefined"||a==null){
        return "";
    }else{
        return a;
    }
}
iP.load=function(){
    uexWindow.toast("1","5","请稍等",0);  
    //var url="http://172.31.3.190:8080/mpservice/hotel_getHotel.action"
    var url="http://mpservice.ceair.com/mpservice/hotel_getHotel.action"
    var airport=$("[code]").attr("code");
    //airport="CTU";
        $.ajax({
        type : "post", 
        contentType: 'application/json',
        dataType:"json", 
        url : url+"?airport="+airport+"&distance="+distance+"&pageNo="+index+"&pageSize=10",
        data:'', 
        cache:false,
        success : function(data){
            uexWindow.closeToast();
            console.log(JSON.stringify(data));
            if(data.recordCount/10<=1){
                totalPage==0;
            }else{
                totalPage=parseInt(data.recordCount/10);
            }
            var html='';
            for(var i in data.result){
                var HotelName=data.result[i].HotelName;
                var AddressLine=iP.renull(data.result[i].Address.AddressLine);
                var CityName=data.result[i].Address.CityName;
                var Phone1=iP.renull(data.result[i].Phone[0]);
                var Phone2=iP.renull(data.result[i].Phone[1]);
                var rates=iP.renull(data.result[i].rates);
                for(var j in rates){
                    rates[j].Description=rates[j].Description.replace(" ","");
                }
                var brates=JSON.stringify(rates);
                if(rates=="")
                rates="(无详细信息)";
                else 
                rates=""; 
                var cla="bbt1"; 
                if(i==data.result.length-1) cla="";
                html+='<div class="p5 '+cla+'" brates='+brates+'>'
                    +'<div>'+HotelName+'</div>'
                    +'<div class="ub mt5">'
                    +'<div class="ub fs9">'
                    +'<div class="c4">电话:</div>'
                    +'<div class="c3 ml7">'+Phone1+"&nbsp;&nbsp;&nbsp;"+Phone2+'</div>'
                    +'</div>'
                    +'</div>'
                    +'<div class="fs9 mt3">'+AddressLine+'</div>'
                    +'<div class="fs9 mt3 c3">'+rates+'</div>'
                    +'</div>'
            }
            $("#list").append(html);
            $("#list").last().removeClass("btt1");
            $("[brates]").click(function(){ 
                var xlist=$(this).attr("brates"); 
                if(xlist==""){
                }else{ 
                    localStorage.setItem("xlist",xlist); 
                    uexWindow.open("Bookinghotelxq_win",0,"Bookinghotelxq_win.html",2,"","","4",280);
                }
            })
        },
        error : function(data){
            uexWindow.closeToast();
            alert(err);
            uexWindow.resetBounceView('0');
            console.log(data);
        }
     });
};
//刷新
iP.pulldown = function(callback){
    var j = 
        {
            "pullToReloadText":"拖动加载",
            "releaseToReloadText":"释放加载",
            "loadingText":"加载中...",
            "loadingImagePath":"res://shuaxin.png"
        }
    var i = 
        {
            "pullToReloadText":"下拉刷新",
            "releaseToReloadText":"释放立即刷新",
            "loadingText":"正在刷新...",
            "loadingImagePath":"res://shuaxin.png"
        }
    uexWindow.setBounce("1");
    uexWindow.setBounceParams('0',JSON.stringify(i));
    uexWindow.setBounceParams('1',JSON.stringify(j));    
    uexWindow.showBounceView("0","#FFF",1);
    uexWindow.showBounceView("1","#FFF",1); 
    uexWindow.notifyBounceEvent("0","1");
    uexWindow.notifyBounceEvent("1","1");
    uexWindow.onBounceStateChange = function(type,status){
        if(type==0 && status==2) {
            index=0;
            $("#list").html('');
            iP.load();
            uexWindow.resetBounceView('0');
        }
        if(type==1 && status==2) {
            index++;
            if(index > totalPage){
                uexWindow.toast("1","5","没有更多了",2000)
                uexWindow.resetBounceView('1');
            }else{
                iP.load();
                uexWindow.resetBounceView('1');
            }
        }        
    }
}
</script>
</html>